<template>
	<view class="wrap">
		<block v-if="isMyClass">
			<view class="card_body">
				<view class="card_cell">
					<view class="card_title">
						学校名称
					</view>
					<view class="card_inp">
						<view class="inpbox">
							{{isMyClass.School}}
						</view>
					</view>
				</view>
				<view class="card_cell">
					<view class="card_title">
						新生/老生
					</view>
					<view class="card_inp">
						<view class="inpbox">
							{{isMyClass.UType }}
						</view>
					</view>
				</view>
				<view class="card_cell">
					<view class="card_title">
						班级
					</view>
					<view class="card_inp">
						<view class="inpbox">
							{{isMyClass.Class}}
						</view>
					</view>
				</view>
				<view class="card_cell">
					<view class="card_title">
						学生姓名
					</view>
					<view class="card_inp">
						<view class="inpbox">
							{{isMyClass.StudentName}}
						</view>
					</view>
				</view>
				<!-- <picker mode="selector"> -->
					<view class="card_cell">
						<view class="card_title">
							性别
						</view>
						<view class="card_inp">
							<view class="inpbox">
								{{isMyClass.Sex}}
							</view>
							<!-- <image src="https://giftapp.oss-cn-shenzhen.aliyuncs.com/upload/17453073622021044.png" mode="heightFix"></image> -->
						</view>
					</view>				
				<!-- </picker> -->
				<view class="card_cell">
					<view class="card_title">
						家长姓名
					</view>
					<view class="card_inp">
						<view class="inpbox">
							{{isMyClass.Parents}}
						</view>
					</view>
				</view>
				<view class="card_cell">
					<view class="card_title">
						联系方式
					</view>
					<view class="card_inp">
						<view class="inpbox">
							{{isMyClass.Mobile}}
						</view>
					</view>
				</view>
			</view>
			
			<view class="card_body">
				<view class="title_body">
					联系地址
				</view>
				<!-- <picker mode="region" :value="['广东省','广州','天河']" @change="chooseAddressInfo"> -->
					<view class="card_cell">
						<view class="card_title">
							所在地区
						</view>
						<view class="card_inp">
							<view class="inpbox">
								{{addressinfo}}
							</view>
							<!-- <input class="inpbox" type="text" disabled placeholder="请选择所在地区" /> -->
						</view>
					</view>				
				<!-- </picker> -->
				<view class="card_cell card_textarea">
					<view class="card_title">
						详细地址
					</view>
					<view class="card_inp">
						<textarea type="text" v-model="isMyClass.Address" disabled disable-default-padding maxlength="50" placeholder="请输入详细地址" />
			
					</view>
				</view>
			</view>
			
			<view style="height: 160rpx;"></view>
			<view class="saveBox">
				<view class="btn saveBtn" @click="editFun()">编辑</view>
			</view>
		</block>
		
		<block v-else>
			<EmptyBox text="还没有班级哦~"></EmptyBox>
			<view class="add_btn" @click="nav_to('/pages/class/editClass')">
				添加班级
			</view>
		</block>
		
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				region:[],
				isMyClass:false
			};
		},
		onLoad() {
		},
		onShow() {
			this.getClass()
		},
		computed: {
			addressinfo(){
				let list = this.region;
				if (list[0] == list[1]) {
					list.splice(0,1)
				}
				return list.join('') || '暂无信息';
			},
		},
		methods:{
			async getClass(){
				let res = await this.$api.post('/Class/MyClass')
				this.isMyClass = res.data || false
				if(this.isMyClass){
					this.region = [
						this.isMyClass.Province || '',
						this.isMyClass.City || '',
						this.isMyClass.Area || '',
					]
				}
			},
			editFun(){
				this.nav_to('/pages/class/editClass?mold=1')
			},
			chooseAddressInfo(e) {
				console.log('picker发送选择改变，携带值为', e)
				this.region = e.detail.value;
			},
		}
	}
</script>

<style lang="scss">
page{
	background-color: #f6f6f6;
}
.wrap{
	.card_body{
		margin-bottom: 20rpx;
		.title_body{
			font-size: 30rpx;
			font-weight: bold;
			color: #000;
			margin:0 0 8rpx 24rpx;
		}
		.card_cell{
			background-color: #fff;
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 110rpx;
			padding: 0 24rpx;
			border-bottom: 1rpx solid #E4E4E4;
		
			.card_title{
				font-size: 32rpx;
				color: #333333;
				width: max-content;
				min-width: max-content;
			}
			.card_inp{
				flex: 1;
				height: 100%;
				display: flex;
				align-items: center;
				.inpbox{
					flex: 1;
					margin-left: 24rpx;
					height: 100%;
					display: flex;
					align-items: center;
					justify-content: flex-end;
				}
				input{
					display: block !important;
					text-align: right;
				}
				image{
					margin-left: 8rpx;
					width: 20rpx;
					height: 30rpx;
				}
			}
			
		}
		.card_textarea{
			padding: 24rpx;
			height: 170rpx;
			.card_title{
				justify-content: flex-start;
				height: 100%;
			}
			.card_inp{
				textarea{
					width: 100%;
					min-height: 120rpx;
					height: 120rpx;
					padding: 0;
					font-size: 32rpx;
					color: #000;
					flex: 1;
					margin-left: 20rpx;
					box-sizing: border-box;
					text-align: right;
				}
			}
			
		}
	}
	
	.saveBox {
		position: fixed;
		width: 100%;
		height: 158rpx;
		box-sizing: border-box;
		left: 0;
		bottom: 0;
		padding: 20rpx 50rpx;
		background-color: #fff;
		display: flex;
		justify-content: center;
	
		.saveBtn {
			width: 670rpx;
			height: 88rpx;
			background: linear-gradient(98deg, #a6c8ff 0%, #5d8bf8 100%);
			border-radius: 44rpx;
			font-weight: bold;
			font-size: 32rpx;
			color: #FFFFFF;
		}
	}
}
.add_btn{
	width: 570rpx;
	height: 88rpx;
	background: linear-gradient(98deg, #a6c8ff 0%, #5d8bf8 100%);
	border-radius: 44rpx;
	font-weight: bold;
	font-size: 32rpx;
	color: #FFFFFF;
	margin: 20rpx auto;
	display: flex;
	align-items: center;
	justify-content: center;
}
</style>
